package com.ocom.mjrecode.controller;


import com.ocom.common.constant.MjRecodeUrl;
import com.ocom.common.enums.ResultEnum;
import com.ocom.common.request.access.AddAttendanceReq;
import com.ocom.common.resp.Result;
import com.ocom.common.utils.ResultUtil;
import com.ocom.mjrecode.service.MjAttendanceService;
import com.ocom.mjrecode.service.MjRecodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;


@RestController
public class TimerController {

    @Autowired
    MjRecodeService mjRecodeService;

    @Autowired
    private MjAttendanceService mjAttendanceService;

    //进
    @PostMapping(value = MjRecodeUrl.URLR_addAttendanceData)
    public Result addAttendanceData(@RequestBody AddAttendanceReq request){
        try {
            System.out.println(request);
            if(request.getTimeType()==1){
                mjRecodeService.addInsideData(request);
            }else{
                mjAttendanceService.addOutdoorData(request);
            }
            return ResultUtil.success();
        }catch (Exception e){
            return ResultUtil.error(ResultEnum.Err_4118);
        }

    }



}
